
// ::
function setPnD2(wW,wH,wPX,wPY)
{
	if (!sessVars["window_maximized"])
	{
		window.resizeTo (wW, wH);
		window.moveTo (wPX, wPY);
		sessVars["window_maximized"] = true;
	}
}

// ::
function setPnD(wW,wH)
{
	var wPX, wPY;
	if (!sessVars["window_maximized"])
	{
		wPX = screen.width/2-wW/2;
		wPY = screen.height/2-wH/2;
		window.resizeTo (wW, wH);
		window.moveTo (wPX, wPY);
		sessVars["window_maximized"] = true;
	}
	return true;
}

// ::
function ShowAlert2Div_() {
	return true;
}

// ::
function HideAlert2Div_() {
	return true;
}

// ::
function ShowAlertDiv_(szMess,szRun, szTtl)
{

	Logging("ShowAlertDiv_ :: \t" + szMess);

	if (sessVars["window_maximized"] == false)
	{

		//BUG

		setPnD(600,448);
	}


	HideSelects();
	//HideScenarioButtons();
	szContinueWith = szRun;	
	document.all["alertdiv_mess"].innerText = szMess;
	document.all["alertdiv_btn"].value=szTtl;
	document.all["alertdiv_btn"].onclick=setTimeout_;
	document.all["alertdiv"].style.visibility = "visible";
	
	// window.resize

	return true;	
}

// ::
function ShowAlertDiv(szMess,szRun, szTtl)
{
	Logging("ShowAlertDiv :: \t" + szMess);

	//HideSelects();
	//HideScenarioButtons();
	//szContinueWith = szRun;	

	if (typeof top.frames["iFrame_scenario"].ShowAlertDiv == "function")
	{
		top.frames["iFrame_scenario"].ShowAlertDiv(szMess,szRun, szTtl);
	}
	else
	{

	// [.] AG 041006
	Logging("ShowAlertDiv :: \tstarted from top frame");
	top.ShowAlertDiv(szMess,szRun,szTtl);

	}
	return true;
}

// ::
function ShowAlert2Div(szMess,szRun1,szRun2,szTtl1,szTtl2)
{
	Logging(szMess);
	Logging(typeof top.frames["iFrame_scenario"].ShowAlert2Div)
	if (typeof top.frames["iFrame_scenario"].ShowAlert2Div == "function")
	{
		Logging('typeof top.frames["iFrame_scenario"].ShowAlert2Div == "function"')
		top.frames["iFrame_scenario"].ShowAlert2Div(szMess,szRun1,szRun2,szTtl1,szTtl2);
//		top.iFrame_scenario.ShowAlert2Div(szMess,szRun1,szRun2,szTtl1,szTtl2);

	}
//	else
//	{
//		// [.] AG 041006
//		Logging("ShowAlert2Div :: \tstarted from top frame");
//		top.ShowAlert2Div(szMess,szRun1,szRun2,szTtl1,szTtl2);
//	}
}

// ::
function RegisterDevice()
{
	Err = false;
	if (typeof top.frames["iFrame_scenario"].RegisterDevice == "function")
	{
		Err = top.frames["iFrame_scenario"].RegisterDevice();
	}
	if (Err)
	{
		sessVars["regData_changed"]=true;
	}
}

// ::
function HideAlert2Div()
{
	if (typeof top.frames["iFrame_scenario"].HideAlert2Div == "function")
	{
		top.frames["iFrame_scenario"].HideAlert2Div();
	}
	ShowSelects();
	ShowScenarioButtons();
}

// ::
function HideAlert3Div()
{
	ShowAlertDiv(messages["cant_cancel_download"] , "HideAlertDiv()" , messages["Continue"]);

//	top.frames["iFrame_scenario"].document.all["alertdiv"].style.visibility = "hidden";

	ShowSelects();
	ShowScenarioButtons();
	return true;
}

// ::
function ShowProgressBar()
{
	Logging("ShowProgressBar()");
	HideAlertDiv();
	HideAlert2Div();
	HideSelects();
	if (typeof top.frames["iFrame_scenario"].ShowProgressBar == "function")
	{
		Err = top.frames["iFrame_scenario"].ShowProgressBar();
	}
	return Err;
}

// ::
function HideAlertDiv()
{
	if (typeof top.frames["iFrame_scenario"].HideAlertDiv == "function")
	{
		Err = top.frames["iFrame_scenario"].HideAlertDiv();
	}
	ShowSelects();
	ShowScenarioButtons();
	return true;
}

// ::
function HideProgressBar()
{
	if (typeof top.frames["iFrame_scenario"].HideProgressBar == "function")
	{
		top.frames["iFrame_scenario"].HideProgressBar();
	}
	ShowSelects();
}

// ::
function HideDivs()
{

//! if available

	HideAlertDiv();
	HideAlert2Div();
	HideProgressBar();
}

// ::
function ShowSelects()
{
	var select_tags = initSpecTags("SELECT");
	for (var i=0; i < select_tags.length; i++)
	{
		select_tags[i].style.visibility = "visible";
	}
}

// ::
function ShowScenarioButtons()
{

//!... + add them to focused by tab

var select_tags = initSpecTags("DIV");
	for (var i=0; i < select_tags.length; i++)
	{
		if (select_tags[i].id.indexOf("Nav_Btn_") == 0)
		{

//			select_tags[i].style.visibility = "visible";

		}
	}
}

// ::
function HideScenarioButtons()
{

//!... + remove them from focused by tab

var select_tags = initSpecTags("DIV");
	for (var i=0; i < select_tags.length; i++)
	{
		if (select_tags[i].id.indexOf("Nav_Btn_") == 0)
		{

//			select_tags[i].style.visibility = "hidden";

		}
	}
}

// ::
function HideSelects()
{
	var select_tags = initSpecTags("SELECT");
	for (var i=0; i < select_tags.length; i++)
	{
		select_tags[i].style.visibility = "hidden";
	}
}

// ::
function prepareShortedString (szShortedString, MaxShownCharactersInPath)
{
	szShortingString = szShortedString;
	var L = szShortingString.length;
	if ( L > MaxShownCharactersInPath )
	{
		szShortingString = szShortingString.substr(L - MaxShownCharactersInPath, MaxShownCharactersInPath);
		SlashPos = szShortingString.indexOf('\\');
		if (SlashPos != -1)
		{
			szShortingString = szShortingString.substr(SlashPos, szShortingString.length - SlashPos);
		}
	}	
	if (L != szShortingString.length)
	{
		szShortingString = "..." + szShortingString;
	}
	return szShortingString;
}

// ::
function PB_Action(szAction)
{
	if (typeof top.frames["iFrame_scenario"].PB_Action == "function")
	{
		top.frames["iFrame_scenario"].PB_Action(szAction);
	}
	else
	{
	}
}

// ::
function PB_BtnLabel(szLabel)
{
	if (typeof top.frames["iFrame_scenario"].PB_BtnLabel == "function")
	{
		top.frames["iFrame_scenario"].PB_BtnLabel(szLabel);
	}
}

// ::
function PB_State(propState,szStateText)
{
	if (propState == "state")
	{
		Logging(szStateText);
	}
	if (typeof top.frames["iFrame_scenario"].PB_State == "function")
	{
		top.frames["iFrame_scenario"].PB_State(propState,szStateText);
	}
	else
	{
	}
}

// ::
function PB_All(iPercentage)
{
	iPercentage = Math.round(iPercentage);
	if (typeof top.frames["iFrame_scenario"].PB_All == "function")
	{
		top.frames["iFrame_scenario"].PB_All(iPercentage);
	}
	else
	{
	}
}

// ::
function PB_Qvant(iPercentage)
{
	iPercentage = Math.round(iPercentage);
	if (typeof top.frames["iFrame_scenario"].PB_Qvant == "function")
	{
		top.frames["iFrame_scenario"].PB_Qvant(iPercentage);
	}
	else
	{
	}
}

// ::
function PB_Cursor(szCursor)
{

	//!... переделать в передачу состояний и их обработку

	if (top.frames["iFrame_scenario"].PB_Cursor == "function")
	{
		top.frames["iFrame_scenario"].PB_Cursor();
	}
}				

// ::
function SlideProgressBar(progressbar,starting,ending)
{
	progressbar.style.width = ending;
}

// ::
function All_Cursor(szCursor)
{
	top.frames["iFrame_scenario"].document.body.style.cursor = szCursor;
}

// ::
function vis_page_state()
{

//--- vis for every page

	var obj = top.frames["iFrame_scenario"].document.all["a_mail"];

//if (obj) {

	if (typeof obj != "undefined")
	{
		if (sessVars["installation_status"] == iDone)
		{
			obj.style.cursor = "default";
		}
		else
		{
			if (IE6)
			{
				top.frames["iFrame_scenario"].document.all["a_mail"].style.cursor = "not-allowed";
			}
	}
}

//--- vis for every page

}

// ::
function createBlankDivs()
{

// if

	top.frames["iFrame_scenario"].createAppDiv(); 
	top.frames["iFrame_scenario"].createProgressBar();
	top.frames["iFrame_scenario"].createAlertDiv();
	top.frames["iFrame_scenario"].createAlert2Div();
}

// ::
function DropState()
{
	if (typeof top.frames["iFrame_scenario"].DropState == "function")
	{
		top.frames["iFrame_scenario"].DropState();
	}
	else
	{
	}	
}

// ::
function focusOn()
{
	if (typeof top.frames["iFrame_scenario"].focusOn == "function")
	{
		top.frames["iFrame_scenario"].focusOn();
	}
	else
	{
	}	
}


ReadyToStart_vis = true;